package com.slt.developkitweb.util;

import cn.hutool.core.util.StrUtil;
//import org.apache.commons.codec.binary.Hex;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.Date;
import java.util.UUID;

/**
 * 通用工具类
 */

public class CommonUtils {
    private final Logger logger = LoggerFactory.getLogger(CommonUtils.class);

    /**
     * 生成token
     * @return
     * @throws Exception
     */
    public static String generateSessionToken(String secret) throws Exception {
        String uuid = UUID.randomUUID().toString().replace("-","");
        long milli = LocalDateTime.now().toInstant(ZoneOffset.of("+8")).toEpochMilli();
        String token = uuid+"|"+milli;
        String encrypt = DESUtils.encrypt(token,secret);
        return encrypt;
    }

    /**
     * 生成token
     * @return
     * @throws Exception
     */
    public static String generateSessionTokenForConsole(String secret) throws Exception {
        String uuid = UUID.randomUUID().toString().replace("-","");
        long milli = LocalDateTime.now().toInstant(ZoneOffset.of("+8")).toEpochMilli();
        String token = uuid+"|"+milli;
        String encrypt = DESUtils.encryptforConsole(token,secret);
        return encrypt;
    }

    /**
     * 解密，校验token
     * @return
     * @throws RuntimeException
     */
    public static Boolean checkSessionToken(boolean needDes,boolean needAes,String token,String clientInfo,String methodName) {
        try {
            if(StrUtil.isBlank(token) || StrUtil.isBlank(Sns.WEB_TO_API)){
                return false;
            }
            String decrypt = "";

            if(needDes){
                decrypt = DESUtils.decrypt(token,Sns.WEB_TO_API);
            }else if(needAes){
                decrypt  = AESUtils.AES_Decrypt(token, Sns.WEB_TO_API_AES,"CBC");
            }

            String[] split = decrypt.split("\\|");
            if(StrUtil.isBlank(split[1])){
                return false;
            }
            long nowTime = LocalDateTime.now().toInstant(ZoneOffset.of("+8")).toEpochMilli();
//            Logit.apiOutLog(clientInfo +";"+methodName+";当前时间："+new Date(nowTime) +";token时间："+new Date(Long.valueOf(split[1])));

            //测试环境不校验token方便测试，灰度和生产校验。
            if(StrUtil.equals(Sns.SWITCH_SESSION_TOKEN,"OFF")){
                return true;
            }

            if(nowTime-Long.valueOf(split[1]) > 10*60*1000){
                return false;
            }else{
                return true;
            }
        } catch (RuntimeException e) {
            e.printStackTrace();
            return false;
        }
    }

    /**
     * 解密参数
     * @return
     * @throws Exception
     */
    public static String decryptParm(String secret,String secretParm) throws Exception {
        if(StrUtil.isNotBlank(secretParm) && !"null".equals(secretParm)){
            secretParm = secretParm.replace(" ", "+");
            String parm = DESUtils.decrypt(secretParm,secret);
            return parm;
        }
        return null;
    }

    /**
     * 解密参数，对应后台公共解密
     * @return
     * @throws Exception
     */
    public static String decryptParmForConsole(String secret,String secretParm) throws Exception {
        if(StrUtil.isNotBlank(secretParm) && !"null".equals(secretParm)){
            secretParm = secretParm.replace(" ", "+");
            String parm = DESUtils.decryptForConsole(secretParm,secret);
            return parm;
        }
        return "";
    }

    /**
     * 对应酒店订单详情的idno
     * @return
     * @throws Exception
     */
    public static String decryptParmForIdno(String secretParm) throws Exception {
        if(StrUtil.isNotBlank(secretParm) && !"null".equals(secretParm)){
            secretParm = secretParm.replace(" ", "+");
            String parm = DESUtils.decryptParmForIdno(secretParm);
            return parm;
        }
        return "";
    }

    /**
     * 加密返回结果
     * @return
     * @throws Exception
     */
    public static String encryptParm(String secret,String parm) throws Exception {
        if(StrUtil.isNotBlank(parm) && !"null".equals(parm)){
            String encryptParm = DESUtils.encrypt(parm,secret);
            return encryptParm;
        }
        return null;
    }

    /**
     * 对应后台公共加密
     * @return
     * @throws Exception
     */
    public static String encryptforConsole(String secret,String parm) throws Exception {
        if(StrUtil.isNotBlank(parm) && !"null".equals(parm)){
            String encryptParm = DESUtils.encryptforConsole(parm,secret);
            return encryptParm;
        }
        return null;
    }

    /**
     * 生成des密钥
     * @return
     */
//    public static String generateKey(){
//        try {
//            KeyGenerator keyGenerator = KeyGenerator.getInstance("DES");
//            keyGenerator.init(56);
//            // 生成一个Key
//            SecretKey generateKey = keyGenerator.generateKey();
//            // 转变为字节数组
//            byte[] encoded = generateKey.getEncoded();
//            // 生成密钥字符串
//            String encodeHexString = Hex.encodeHexString(encoded);
//            return encodeHexString;
//        } catch (Exception e) {
//            e.printStackTrace();
//            return "密钥生成错误.";
//        }
//    }

    /**
     * 根据经纬度计算两坐标之间距离
     * @return
     */
    public static String getDistance(Double startLongitude,Double startLatitude,Double endLongitude,Double endLatitude){
        try {
            double lon1 = (Math.PI / 180) * startLongitude;
            double lon2 = (Math.PI / 180) * endLongitude;
            double lat1 = (Math.PI / 180) * startLatitude;
            double lat2 = (Math.PI / 180) * endLatitude;

            // double Lat1r = (Math.PI/180)*(gp1.getLatitudeE6()/1E6);
            // double Lat2r = (Math.PI/180)*(gp2.getLatitudeE6()/1E6);
            // double Lon1r = (Math.PI/180)*(gp1.getLongitudeE6()/1E6);
            // double Lon2r = (Math.PI/180)*(gp2.getLongitudeE6()/1E6);

            // 地球半径
            double R = 6371;
            // 两点间距离 km，如果想要米的话，结果*1000就可以了
            double d = Math.acos(Math.sin(lat1) * Math.sin(lat2) + Math.cos(lat1) * Math.cos(lat2) * Math.cos(lon2 - lon1)) * R;
            System.out.println(d*1000);
            return null;
        } catch (Exception e) {
            e.printStackTrace();
            return "根据经纬度计算两坐标之间距离："+e.getMessage();
        }
    }


    /**
     * 解密参数,AES的cbc模式
     * @return
     * @throws Exception
     */
    public static String decryptParmByAES(String secret,String secretParm) throws Exception {
        if(StrUtil.isNotBlank(secretParm) && !"null".equals(secretParm)){
            secretParm = secretParm.replace(" ", "+");
            String parm = AESUtils.AES_Decrypt(secretParm, secret,"CBC");
            return parm;
        }
        return null;
    }

    /**
     * 加密返回结果
     * @return
     * @throws Exception
     */
    public static String encryptParmByAES(String secret,String parm) throws Exception {
        if(StrUtil.isNotBlank(parm) && !"null".equals(parm)){
            String encryptParm = AESUtils.AES_Encrypt(parm, secret,"CBC");
            return encryptParm;
        }
        return null;
    }

    /*public String httpGetRequest(String urlNameString){
        String result = "";
        try {
            HttpGet request = new HttpGet(urlNameString);//这里发送get请求
            HttpClient httpClient = new DefaultHttpClient();
            HttpResponse response = httpClient.execute(request);
            // 判断网络连接状态码是否正常(0--200都数正常)
            if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
                result= EntityUtils.toString(response.getEntity(),"utf-8");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return result;
    }*/

    public static void main(String[] args) throws Exception {
        String str = "HhzC1QiD8vIeSsXZmyVZc+1H99GyVz7X45Acwl9vgtuPaKRarmx/qkQ0xngNKgL4J7nPEbMMRCA0Qr2QrPe3YwDvjFwSOHbr82HCdN30FMBv8/grhvgLUj6fPKU7Ht1Oh6vJe+PffvnaKf1VwjWuSGN+Uw/YrIT8BJRFQHY/zkrF/wEhYyLxUfNxBt3I6alFSbkV0z4bX5RwhUkrac5B2386vs0DYbqC2XgzgSprdm74OdkSa3U5oGdv3UG5cJ9o8rgV23Rfrc06Ql227Cb7i6D68Dt2gfo1FBmcotWPXsCtSDagL37dylUKcGEBA4Srfma+1afcIm3w9ARpM6oBQuXRT1csx6SvlewAxDevHZHUfnl0JiJJnsA/sCwl8Q2MfomCOIvQr+hjU3BTiyebZt30rc+69d9fd6avXCeIpAnsOAXX9YvizAMTrRnnNu5601XBcgYN/VRKoohqmadumF3MBKIwml9fBAXJmjC43my1OWZGA5ZpLJmIHHqTxNeN90hX1RJr1WV1ySLn5j/fY3ILT7KrFDvqkY6h53/nEyBcwp54D6YN/DjiYj63R4aZjQNql2U0KvHFxd9d6zfk6BpYuijdNpnyfGdJoSbJ0YcHz0qyCArP3dl+dzs3oYy6H5nx3OWGDXpA0/SFkhA9sTGATahOk0Ix/UCyUmaBqXeh5bRBZk6766xh/cHqMGny+T7Ru8nrSOkwqIbJHBhswLSDpaiWHYc9jdS2sP3VGhy0Nq/sbVVLx15+VrK8yvTLv1zPU8oLGBG650f6NmalDZd7cR9tlfc31PtaDfdwv2jXxAVVDkOgPaD99UI7DC0yaOS6qNikjXkyx4e6EXJYpfOxUD/NaAV6XVJEjH0FQft6QJtLCaOWfcCLsKLnsXluayntRD9E6+HTmHa0VB32Up94BwJ9WNYdjcAeMem86ZHNZE0vqF0g0wVrbjb65eNYvpp/jnq/GCQwvVTUyFh6DKbu2Y9XP5yAonwPhNxgYK7LzpBALYhCN59t6jamv3SVkE5GJi8BG3fiTVgYzQ4UNYy3bqq8DtYVi+kbYlWFttkfV4xwqGvLEtH0AHsc1EYDWnim4hMCGd+ctST+QyvdjZXRqOH59hDLGkR2cAMLEKINQWZuz2n8g2MzvuRjbn2Kl+0ENwsPFLtWZSSz8M7so1HtVAGP8WikGQI2FVH0SmGBALV76LOZCpfVjWGZSP6lPpiCB1IxtjzxzrRh1/xii7OSYCZMyGTZjneSKmaXGPyBRnnt6lcxwqg18vNuXzo5xA8P9KYiiju357yvIDjcDje3b/rDWDfLCOtjIVKNi3IyL0E+qjmZ53InZL1lye/dG8X/rTfgMbfN5XgTSqIdarKzfwRsyhnK0q2J6Haq2NDNPnzPE+mq8L5ApdV+aVWH1t7Ov6+Qm9sTTTiI5Mphw7V//lPSy8leaz7CGR1gkkJgaWejw9X5iXm10CT4NUtm";
        String srt = decryptParmByAES("F49E8CAC66C376FC",str);
        System.out.println(srt);
        //dddfff
        /*String [] array1 = {"1","2","3"};
        String [] array2 = {"3","2","1"};*/
        /*String [] array1 = null;
        String [] array2 = null;
//        Arrays.sort(array1);
//        Arrays.sort(array2);
        if (Arrays.equals(array1, array2)) {
            System.out.println("两个数组中的元素值相同");
        } else {
            System.out.println("两个数组中的元素值不相同");
        }*/

//        String key = generateKey();
//        System.out.println("key:"+key);

//        String sessionToken = generateSessionToken(Sns.WEB_TO_API);
//        String sessionToken = generateSessionTokenForConsole(Sns.API_TO_CONSOLE);
//        System.out.println("sessionToken:"+sessionToken);
//
//        String tt = "{\"channel\":\"120\",\"authentication\":\"bjVpdnhpT1l0SWZXdmtkVVQvSWlWb2NnSXFsdXc0VW9IUmZvK1BtWjNQRjNhVDFQOU1CRTdwRDNrTWdseHdnUDdqclYvSmxST1ZpeQ0KRzlBUDBxNlFSZSs0UU9WOFU4cHVkOTZvVXJwMUNBb3pUK0pNbnROdFQ4a0h5b0VBREpYOUkzcmo2YTdDYXU4cUZrT2paVDZvRWpkRw0KWkpqMkwyVnYyb3JybUtFcmFEST0=\"}";
//        tt = Base64Coder.encodeString(tt);
//        String encrypt = DESUtils.encrypt(tt, Sns.WEB_TO_API);
////        String encrypt = encryptforConsole("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa|1583654427", Sns.API_TO_CONSOLE);
//        System.out.println("encrypt:"+encrypt);

        //生成请求链接
//        String authentication = RSAUtil.Test();
//        String source="{\"channel\":\"150\",\"authentication\":\""+authentication+"\",\"h5Version\":\"2.1.6\"}";
//        String urlPrefix = "http://t100.test.cmbuy10086.com:20081/h5/v8/user/auth?h5Str=";
//        String cbc = AESUtils.AES_Encrypt(source, Sns.WEB_TO_API_AES, "CBC");
//        StringBuilder sb = new StringBuilder();
//        sb.append(cbc);
//        sb.append("&&");
//        String sessionToken = generateSessionToken(Sns.WEB_TO_API_AES);
//        sb.append(sessionToken);
//        String req = Base64.getEncoder().encodeToString(sb.toString().getBytes("utf-8"));
//        System.out.println(urlPrefix+req);

        //模拟前端app请求
        /*String jsonStr = FileUtils.readFileToString(new File("C:\\Users\\lujie\\Desktop\\请求报文\\test.json"), "utf-8");
        String cbc = AESUtils.AES_Encrypt(jsonStr, Sns.WEB_TO_API_AES, "CBC");
        String sessionToken = generateSessionToken(Sns.WEB_TO_API_AES);
        StringBuilder sb = new StringBuilder();
        sb.append(cbc);
        sb.append("&&");
        sb.append(sessionToken);
        sb.append("&&");
        sb.append("1111111");
        sb.append("&&");
        String userTokenValue = FastMemcachedCache.generateUUID();
        FastMemcachedCache cache = (FastMemcachedCache) SpringHelper.getBean("FastMemcachedCache");
        cache.add(TravelCache.USER_TOKEN+userTokenValue,"0",TravelCache.DUE_QUARTER_MIN);
        sb.append(TravelCache.USER_TOKEN+userTokenValue);
        String sbString = sb.toString();
        String h5Str = new String(new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4TFTOcCySfl1EHkQWzFP24z5vG6VbPLNb0heNSgBYnLZU2KJvk0nnM4nsINoYIPcWmuAjEXYctAkWPw/WtoWr8RWoomU2cpf+den0VBPotN9hhf5Am3kHX+3aMuqgA4atdyA6iVfHtpOZurhoruKA2idbgtqucospz92D3wFU2afFADTrY98iHIvjPH8qbMAdU2n4imsn+TpwQNu4caX41p2r3svWd7ZiRALsFrU7prYXX/cs+yfzCK0em6HTlSP0z02G+p";
//        String tt = "4MM/GFNwxy7GcnVleQSb54GC/8hsxgr0QG/DxcViFqXd3pFshsOeB3eiGILBYI1hj0NKwPICEKcDLaVxBeoR9Ifw6nWJOkmIIuzdb/8zGdlBY4xDNmy+08j1A+i5YTKEYn/BL5E2d8Zve0YLHEjnNiLC8YVl+tXxUNIxJvWEwKYGXMXPXIBohDThOUnukkojiDUOyYsHmY5PMmiI/hsXqKfK2AdA/zIJ+Dw83VNfHBs=";
//        String decrypt = AESUtils.AES_Decrypt(tt, Sns.WEB_TO_API_AES,"CBC");
//        System.out.println(decrypt);
//        String tt = "9VquPUpdPxY=";
//        String decrypt = decryptParmForIdno(tt);
//        String s = Base64Coder.decodeString(decrypt);
//        System.out.println(decrypt);
//        System.out.println(s);

//        String tt = "6/Qw5sKUUE9K3rVvJ3Ob2LNlYtfvHwP+7YwOCM3nSXFHn3gdMj8t0w==";
//        String view_id = DESUtils.decrypt(tt,Sns.WEB_TO_API);
//        System.out.println(view_id);
//        String retJson = "{\"status\": 1000,\"msg\": \"定制成功\",\"data\": null}";
//        Map rstMap = JSON.parseObject(retJson,Map.class);
//        System.out.println(JSON.toJSONString(rstMap));

//        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
//        Date date = sdf.parse("20200612");
//        SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd");
//        String subsDate = sdf2.format(date);
//        System.out.println(subsDate);

//        getDistance(116.319802,39.982940,116.29345000000001,39.98925);
//        getDistance(116.319802,39.982940,116.309,39.9782);
//        getDistance(116.319802,39.982940,116.312202215194,39.9672535640845);
//        getDistance(116.319802,39.982940,116.302728652954,39.9661352670032);
//        getDistance(116.319802,39.982940,116.35,39.9875);
//
//        getDistance(116.319802,39.982940,116.352928876876,39.9875770697898);
//        getDistance(116.319802,39.982940,116.318956,39.989831);
//        getDistance(116.319802,39.982940,116.311801,39.977643);

//        String ss = "{\"Code\":0,\"Msg\":\"调用成功\",\"Data\":{\"DealNo\":\"CANYQF20200813111640980\",\"Msg\":null,\"Code\":0,\"Timestamp\":null,\"PolicyInfos\":[{\"PolicyNo\":\"784483493761000\",\"PrintUrl\":null,\"TradeNo\":\"HTI202008130006148368\",\"TradeRemark\":\"投保成功\",\"TradeStatus\":1}]}}\n";
//        Map mapType = JSON.parseObject(ss,Map.class);
//        System.out.println(mapType.get("Data"));
//        for (Object obj : mapType.keySet()){
//            System.out.println("key为："+obj+"值为："+mapType.get(obj));
//        }
//        Object ss = null;
//        System.out.println((String)ss);
//        String str = "E44F074CCB7FC53BD52B62EE670C072AB3201F5A78CE59066D20078053B23D85F48345ED323469501F05358D35BEE17D";
//        String decrypt = DESUtils.decryptForConsole(str,"843D030BD897DE48");
//        System.out.println(LocalDateTime.now().toInstant(ZoneOffset.of("+8")).toEpochMilli());
//        System.out.println(decrypt);
//        String url = "https://appdownload.cmbuy.cn/test/getfile/jVwt3t2SE-ArEB+rE-6rEg2W3tbT4BMUetjr4hEV4C6Ue+==.ipa";
//        int i = url.lastIndexOf("/");
//        url = url.substring(i+1);
//        System.out.println(url);
    }
}
